﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using System.Windows;
using System.Windows.Media;

namespace TextGlow.Control.Utilities
{
  public static class LayoutUtils
  {
    public static readonly Point Zero = new Point(0, 0);
    public static readonly Size InfiniteSize = new Size(double.PositiveInfinity, double.PositiveInfinity);

    public static Rect CreateRect(Point point, Size size)
    {
      return new Rect(point.X, point.Y, size.Width, size.Height);
    }

    public static Rect Offset(this Rect e, double x, double y)
    {
      return new Rect(e.X + x, e.Y + y, e.Width, e.Height);
    }

    public static Point Offset(this Point e, double x, double y)
    {
      return new Point(e.X + x, e.Y + y);
    }

    public static Rect SetSize(this Rect r, Size s)
    {
      return new Rect(r.X, r.Y, s.Width, s.Height);
    }

    public static Point GetLocation(this Rect r)
    {
      return new Point(r.X, r.Y);
    }

    public static Size GetSize(this Rect r)
    {
      return new Size(r.Width, r.Height);
    }

    public static Point GetBottomLeft(this Rect r)
    {
      return new Point(r.Left, r.Bottom);
    }

    public static Point GetBottomRight(this Rect r)
    {
      return new Point(r.Right, r.Bottom);
    }

    public static Point GetTopLeft(this Rect r)
    {
      return new Point(r.Left, r.Top);
    }

    public static Point GetTopRight(this Rect r)
    {
      return new Point(r.Right, r.Top);
    }
  }
}